home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-12 | 8.5 KB | 315 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "IntlTest.hpp"
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef VIEW_H
- #include "View.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- #ifndef EDITVIEWS_H
- #include "EditViews.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWEDVIEW_H
- #include "FWEdView.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWIDLE_H
- #include "FWIdle.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWSTATIC_H
- #include "FWStatic.h"
- #endif
-
- #ifndef FWTABBER_H
- #include "FWTabber.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- // ----- Graphic Includes -----
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfIntlTest
- #endif
-
- //========================================================================================
- // CIntlTestFrame class
- //========================================================================================
-
- FW_DEFINE_AUTO(CIntlTestFrame)
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame constructor
- //----------------------------------------------------------------------------------------
- CIntlTestFrame::CIntlTestFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CIntlTestPart* part) :
- FW_CFrame(ev, odFrame, presentation, part),
- FW_MDroppableFrame(ev, this),
- FW_MReceiver(),
- fTestPart(part),
- fTestView(NULL),
- fTestSelection((CIntlTestSelection*)presentation->GetSelection(ev)),
- fViewTabber(NULL)
- {
- FW_CIdler* idler = FW_NEW(FW_CIdler, (this, 15));
- idler->RegisterIdle(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame destructor
- //----------------------------------------------------------------------------------------
-
- CIntlTestFrame::~CIntlTestFrame()
- {
- // fViewTabber is deleted automatically because it's an attached event handler
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CIntlTestFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CRect frameRect = GetBounds(ev);
- FW_CRect centerRect(GetFrame(ev)->GetContentView(ev)->GetBounds(ev));
-
- // Draw a gray background around the content view if it's smaller
- if (centerRect.right < frameRect.right || centerRect.bottom < frameRect.bottom ) {
-
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- // Draw outside the center view to avoid flashing
- FW_CAcquiredODShape aqPaneShape = ::FW_NewODShape(ev, frameRect);
- FW_CAcquiredODShape aqCenterShape = ::FW_NewODShape(ev, centerRect);
- aqPaneShape->Subtract(ev, aqCenterShape);
-
- FW_CRegionShape::RenderRegion(vc, aqPaneShape, FW_kFill, FW_kRGBLightGray);
-
- // Draw a shadow frame around the content view
- centerRect.Inset(-FW_IntToFixed(1),-FW_IntToFixed(1));
- FW_CRectShape::RenderRect(vc, centerRect, FW_kFrame);
- FW_CPoint p1(centerRect.left, centerRect.bottom);
- FW_CPoint p2(centerRect.right, centerRect.bottom);
- FW_CPoint p3(centerRect.right, centerRect.top);
- FW_CLineShape::RenderLine(vc, p1, p2);
- FW_CLineShape::RenderLine(vc, p2, p3);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame::NewClipboardCommand
- //----------------------------------------------------------------------------------------
-
- FW_CClipboardCommand* CIntlTestFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- FW_CEditView* editView = NULL;
- ODID id = this->GetActiveEditViewId(ev);
- if (id)
- {
- editView = this->FindEditView(ev, id);
- }
-
- CIntlTestEditCommand* cmd = FW_NEW(CIntlTestEditCommand, (ev, commandID, this, fTestSelection, editView, FW_kCanUndo));
- return cmd;
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CIntlTestFrame::NewDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint)
- {
- FW_UNUSED(frame);
-
- FW_CEditView* dropView = this->HitTest(ev, dropPoint);
- if (dropView)
- return FW_NEW(CIntlTestDropCommand, (ev, this, dropView, fTestSelection, dropInfo, odFacet, dropPoint));
-
- // dropPoint isn't in an edit view
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CIntlTestFrame::CreateSubViews
- //----------------------------------------------------------------------------------------
- void CIntlTestFrame::CreateSubViews(Environment* ev)
- {
- // ----- Create the content view
- FW_CPoint extent;
- FW_CRect contentRect;
- GetContentRect(ev, contentRect, extent);
- CIntlTestView* contentView = new CIntlTestView(ev, this, contentRect, extent);
- contentView->BecomeContentView(ev);
- fTestView = contentView;
-
- // ----- Read the subviews from resource
- contentView->CreateSubViewsFromResource(ev, kIntlTestView);
-
- // ----- Add a ViewTabber to the frame
- fViewTabber = new FW_CViewTabber(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- ODID CIntlTestFrame::GetActiveEditViewId(Environment* ev)
- {
- FW_MEventHandler* target = this->GetTarget(ev);
- if (target)
- {
- FW_CView* targetView = FW_DYNAMIC_CAST(FW_CView, target);
- if (targetView)
- return targetView->GetViewID(ev);
- }
-
- return 0;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CEditView* CIntlTestFrame::FindEditView(Environment* ev, ODID id)
- {
- return (FW_CEditView*) fTestView->FindViewByID(ev, id);
- }
-
- //----------------------------------------------------------------------------------------
- void CIntlTestFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CFrame::FacetAdded(ev, facet, facetCount); // Call inherited
-
- // Perform "DoPostCreate"-type initialization here.
- fTestPart->UpdateViewsFromTextData(ev);
- }
-
- //----------------------------------------------------------------------------------------
- void CIntlTestFrame::HandleNotification(Environment* ev, const FW_CNotification& notification)
- {
- // ---- Handle notification messages from the edit views
- if (notification.GetMessage() == kEditViewMsg)
- {
- fTestPart->Changed(ev); // so we can Save
- }
- }
-
- //----------------------------------------------------------------------------------------
- void CIntlTestFrame::GetContentRect(Environment* ev, FW_CRect& rect, FW_CPoint& extent)
- {
- rect = GetBounds(ev);
-
- // Leave space to draw 1 pixel border in non-root frames
- if (IsRoot(ev) == FALSE)
- rect.Inset(FW_kFixedPos1);
-
- extent = rect.BotRight();
-
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
- rect.right -= sbSize.x;
- rect.bottom -= sbSize.y;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CEditView* CIntlTestFrame::HitTest(Environment* ev, const FW_CPoint& where)
- {
- // Find out which edit view the point is in; return NULL if point is not in an edit view.
- FW_CEditView* editView;
- FW_CRect bounds;
-
- editView = this->FindEditView(ev, kJapaneseEditView);
- bounds = editView->GetBounds(ev);
- if (bounds.Contains(where))
- return editView;
-
- editView = this->FindEditView(ev, kEnglishEditView);
- bounds = editView->GetBounds(ev);
- if (bounds.Contains(where))
- return editView;
-
- return NULL;
- }
-
-